info = {"name": "张三", "level": {"type": "啊啊"}}
info["level"]["type"] = "newval"
print(f"看看对象{info}")

# 删除元素 //js是delete info.name
## 删除某个键值对
popval = info.pop("name")  # 可以把值获取到，同时该键值对从对象里删除
print(f"字典取出了{popval},现在的字典状态{info}")
print("------------------------------")

## 清空字典
info.clear()
print(f"字典清空后{info}")
print("------------------------------")

# 获取全部的key
info = {"李白": 10, "杜甫": 30, "桃乃木": 50}
keys = info.keys()
values=info.values() # 输出所有值
print(f"字典全部key是{keys}")
print(f"字典全部key是{values}")
print("------------------------------")

# 遍历字典
for key in keys:
    print(f"字典的key是{key},val是{info[key]}\t")

for key in info:
    print(f"key:{key},val:{info[key]}\t")
print("------------------------------")

# 计算字典内的元素数量
num = len(info)
print(f"字典中的元素数量有：{num}个")
